﻿//给出一个字符串，求最长非回文子字符串的长度

#include <iostream>
#include <string>
using namespace std;
int n;
string s;
int fun()
{
	// 1. 判断是否全都是相同字符
	bool flag = false;
	for (int i = 1; i < n; i++)
	{
		if (s[i] != s[0])
		{
			flag = true;
			break;
		}
	}
	if (flag == false) return 0;
	// 2. 判断本⾝是否是回⽂
	flag = true;
	int left = 0, right = n - 1;
	while (left < right)
	{
		if (s[left] == s[right])
		{
			left++;
			right--;
		}
		else
		{
			flag = false;
			break;
		}
	}

	if (flag) return n - 1;
	else return n;
}
int main()
{
	cin >> s;
	n = s.size();

	cout << fun() << endl;

	return 0;
}










